﻿using SqlSugar;
using SwaggerJwtAuthenticationCenter.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace SwaggerJwtAuthenticationCenter.DbHelper.Base
{
    public interface IBaseRepository
    {
        IAdo Ado<T>();
        Task<List<T>> QueryListBySql<T>(string sql) where T : class, new();
        Task<T> QuerySingleBySql<T>(string sql) where T : class, new();
        Task<bool> ExecuteSql<T>(string sql, List<SugarParameter> parameters = null) where T : class, new();
        Task<T> QuerySingle<T>(Expression<Func<T, bool>> expression) where T : class, new();
        Task<T> QueryById<T>(object objId) where T : class, new();
        Task<T> QueryById<T>(object objId, bool blnUseCache = false) where T : class, new();
        Task<List<T>> QueryByIDs<T>(object[] lstIds) where T : class, new();
        Task<int> Add<T>(T model) where T : class, new();
        Task<bool> DeleteById<T>(object id) where T : class, new();
        Task<bool> Delete<T>(T model) where T : class, new();
        Task<bool> DeleteByIds<T>(object[] ids) where T : class, new();
        Task<bool> Update<T>(T model) where T : class, new();
        Task<bool> Update<T>(T entity, string strWhere) where T : class, new();
        Task<bool> Update<T>(object operateAnonymousObjects) where T : class, new();
        Task<bool> Update<T>(T entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string strWhere = "") where T : class, new();
        Task<List<T>> Query<T>() where T : class, new();
        Task<List<T>> Query<T>(string strWhere) where T : class, new();
        Task<List<T>> Query<T>(Expression<Func<T, bool>> whereExpression) where T : class, new();
        Task<List<T>> Query<T>(Expression<Func<T, bool>> whereExpression, string strOrderByFileds) where T : class, new();
        Task<List<T>> Query<T>(Expression<Func<T, bool>> whereExpression, Expression<Func<T, object>> orderByExpression, bool isAsc = true) where T : class, new();
        Task<List<T>> Query<T>(string strWhere, string strOrderByFileds) where T : class, new();
        Task<List<T>> Query<T>(Expression<Func<T, bool>> whereExpression, int intTop, string strOrderByFileds) where T : class, new();
        Task<List<T>> Query<T>(string strWhere, int intTop, string strOrderByFileds) where T : class, new();
        Task<List<T>> Query<T>(Expression<Func<T, bool>> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds) where T : class, new();
        Task<List<T>> Query<T>(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds) where T : class, new();
        Task<PageModel<T>> QueryPage<T>(Expression<Func<T, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new();
        Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, TResult>> selectExpression, Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new();
        Task<List<TResult>> QueryMuch<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> atselectExpression, Expression<Func<T, T2, bool>> whereLambda = null) where T : class, new();
        Task<List<TResult>> QueryMuch<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, string whereStr = null) where T : class, new();
    }
}
